package cn.js.sangu.unitStore.utils;

import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbException;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileOutputStream;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.UnknownHostException;

public class SmbUtil {


    public static void main(String[] args) throws IOException {

        String domain = "";
        String user = "001";
        String pwd = "123456";
        String path = "smb://192.168.111.165//研发公盘//001//UnitStore//File//test.txt";

        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(domain, user, pwd);

        SmbFile smbFile = new SmbFile(path,auth);

        try(SmbFileOutputStream outputStream = new SmbFileOutputStream(smbFile)) {
            String content = "Hello, SMB!";
            outputStream.write(content.getBytes());
            System.out.println("File written successfully!");
        } catch (SmbException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }


    }
}
